from django.shortcuts import render


def handler_404(request, exception):
    code = 404
    context = {
        'code': code,
        'message': '找不到对应的内容哦，看看网址是不是有问题吧！',
    }
    if request.user.is_authenticated:
        return render(request, 'error.html', context=context, status=code)
    return render(request, 'authentication/error.html', context=context, status=code)


def handler_500(request):
    code = 500
    context = {
        'code': code,
        'message': '服务器错误，快提醒开发部成员修一修！',
    }
    if request.user.is_authenticated:
        return render(request, 'error.html', context=context, status=code)
    return render(request, 'authentication/error.html', context=context, status=code)
